import cv2

def callback(event, x, y, flags, param):
    pass

cv2.namedWindow('clior', cv2.WINDOW_NORMAL)
img = cv2.imread("C:\\Users\\86191\\Pictures\\Saved Pictures\\Camera Roll\\face.jpg")
# 色彩空间
cl = [cv2.COLOR_BGR2GRAY,cv2.COLOR_BGR2RGB, cv2.COLOR_BGR2HSV, cv2.COLOR_BGR2LUV,cv2.COLOR_BGR2RGB]
# 创建控件
cv2.createTrackbar('color', 'clior', 0, len(cl),callback)

while True:
    # 获取OpenCV中轨迹条的位置
    index = cv2.getTrackbarPos('color', 'clior')
    # 色彩转换
    cvt_img = cv2.cvtColor(img, cl[index])
    cv2.imshow('clior', cvt_img)
    k = cv2.waitKey(1)
    if k & 0xFF == ord('q'):
        break

cv2.destroyAllWindows()